// MainFrm.cpp : implmentation of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "CGMainFrame.h"

BOOL CGMainFrame::PreTranslateMessage(MSG* pMsg)
{
	return CFrameWindowImpl<CGMainFrame>::PreTranslateMessage(pMsg);
}

BOOL CGMainFrame::OnIdle()
{
	return FALSE;
}

LRESULT CGMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{	
	m_thumbView.Create(*this);
	m_thumbView.SetLocation(L".");
	m_hWndClient = m_thumbView;
	
	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	DragAcceptFiles(TRUE);

	return 0;
}

LRESULT CGMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
	DragAcceptFiles(FALSE);
	
	// unregister message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->RemoveMessageFilter(this);
	pLoop->RemoveIdleHandler(this);

	bHandled = FALSE;
	return 1;
}

void CGMainFrame::OnDropFiles(HDROP hDropInfo)
{	
	wchar_t filePath[MAX_PATH];
	DragQueryFile(hDropInfo, 0, filePath, _countof(filePath));
	m_thumbView.SetLocation(filePath);
}

LRESULT CGMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	PostMessage(WM_CLOSE);
	return 0;
}




